package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.Staff;
import com.ruoyi.service.IStaffService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工签到记录Controller
 *
 * @author ruoyi
 * @date 2025-11-02
 */
@RestController
@RequestMapping("/sign/staff")
public class StaffController extends BaseController
{
    @Autowired
    private IStaffService staffService;

    /**
     * 查询员工签到记录列表
     */
    @PreAuthorize("@ss.hasPermi('sign:staff:list')")
    @GetMapping("/list")
    public TableDataInfo list(Staff staff)
    {
        startPage();
        List<Staff> list = staffService.selectStaffList(staff);
        return getDataTable(list);
    }

    /**
     * 导出员工签到记录列表
     */
    @Log(title = "员工签到记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Staff staff)
    {
        List<Staff> list = staffService.selectStaffList(staff);
        ExcelUtil<Staff> util = new ExcelUtil<Staff>(Staff.class);
        util.exportExcel(response, list, "员工签到记录数据");
    }

    /**
     * 获取员工签到记录详细信息
     */
    @GetMapping(value = "/{sId}")
    public AjaxResult getInfo(@PathVariable("sId") Long sId)
    {
        return success(staffService.selectStaffBySId(sId));
    }

    @PreAuthorize("@ss.hasPermi('sign:staff:query')")
    @GetMapping("/monthlyStats")
    public AjaxResult getMonthlyStats(Staff staff)
    {
        return success(staffService.selectMonthlyAttendanceStats(staff));
    }
}
